package com.paireach.szwolaiyun.util;

import android.content.Context;
import android.util.Log;

import com.paireach.szwolaiyun.sz_util.SharedPreferencesUtil;

import java.util.Set;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;

/**
 * Created by Administrator on 2016/6/21.
 */
public class JPushUtil {

    /**
     * 极光推送设置别名
     * @param context
     */
    public  void setAlias(Context context){
        Log.e("0011","设置极光推送别名"+ SharedPreferencesUtil.getValue(context, SharedPreferencesUtil.USER_PHONE));
        JPushInterface.setAliasAndTags(context, SharedPreferencesUtil.getValue(context, SharedPreferencesUtil.USER_PHONE), null, mAliasCallback);
    }

    private final TagAliasCallback mAliasCallback = new TagAliasCallback() {

        @Override
        public void gotResult(int code, String alias, Set<String> tags) {
            String logs;
            switch (code) {
                case 0:
                    logs = "注册别名成功。";
                    Log.e("0011", logs);
                    break;

                case 6002:
                    logs = "设置别名超时，请注销账号重新登录！";
                    Log.e("0011", logs);

                    break;

                default:
                    logs = "Failed with errorCode = " + code;
                    Log.e("0011", logs);
            }
//			 ExampleUtil.showToast(logs, getApplicationContext());
        }

    };
}
